{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "49f89208",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Scanning 'VOCData\\train.cache' images and labels... 813 found, 0 missing, 564 empty, 0 corrupted: 100%|█| 813/813 [00:0\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mRunning kmeans for 12 anchors on 698 points...\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.81 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.448/0.821-mean/best, past_thr=0.507-mean: 19,24,  32,28,  25,51,  42,40,  47,63,  62,49,  40,95,  92,44,  80,81,  47,147,  89,133,  156,114\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mEvolving anchors with Genetic Algorithm: fitness = 0.8230:  32%|██▏    | 158/500 [00:00<00:00, 1568.56it/s]\u001b[0m"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.77 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.448/0.821-mean/best, past_thr=0.508-mean: 19,24,  29,29,  25,50,  42,40,  46,63,  60,48,  39,98,  93,45,  82,80,  46,145,  88,133,  162,112\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.79 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.449/0.821-mean/best, past_thr=0.508-mean: 19,24,  29,30,  25,50,  41,40,  47,60,  61,48,  41,98,  93,44,  82,80,  46,145,  87,136,  156,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.80 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.449/0.821-mean/best, past_thr=0.508-mean: 19,25,  29,30,  25,50,  41,40,  47,60,  61,48,  41,97,  94,44,  82,80,  46,145,  87,136,  156,116\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.80 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.449/0.822-mean/best, past_thr=0.508-mean: 19,25,  29,30,  25,50,  41,39,  47,60,  60,48,  94,43,  42,97,  82,78,  47,145,  86,136,  156,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.81 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.450/0.822-mean/best, past_thr=0.508-mean: 19,24,  28,29,  25,49,  41,40,  47,60,  60,48,  94,43,  42,98,  82,78,  47,145,  86,136,  156,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.80 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.449/0.822-mean/best, past_thr=0.508-mean: 19,25,  28,29,  25,50,  41,39,  47,61,  60,48,  95,43,  42,98,  82,77,  47,146,  85,136,  156,114\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.80 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.449/0.822-mean/best, past_thr=0.508-mean: 18,25,  28,30,  24,49,  41,38,  46,59,  59,48,  95,43,  44,98,  82,76,  47,142,  86,138,  157,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.81 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.450/0.822-mean/best, past_thr=0.509-mean: 19,24,  28,31,  25,49,  42,38,  47,58,  58,47,  95,43,  44,98,  80,75,  46,144,  86,136,  158,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.80 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.450/0.822-mean/best, past_thr=0.509-mean: 19,24,  28,30,  25,49,  42,38,  46,58,  58,47,  95,43,  43,98,  80,75,  46,144,  86,137,  158,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.82 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.450/0.823-mean/best, past_thr=0.509-mean: 19,24,  28,30,  25,49,  42,38,  46,58,  57,47,  95,43,  43,99,  80,75,  46,143,  86,135,  158,111\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.81 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.451/0.823-mean/best, past_thr=0.509-mean: 19,24,  28,30,  25,49,  42,38,  46,58,  57,47,  95,43,  43,99,  80,75,  46,143,  86,135,  158,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.89 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.823-mean/best, past_thr=0.512-mean: 19,23,  29,30,  25,48,  41,39,  47,58,  57,48,  88,41,  44,97,  81,77,  48,146,  86,127,  154,107\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.92 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.456/0.823-mean/best, past_thr=0.512-mean: 19,23,  28,30,  26,48,  40,39,  46,57,  57,49,  89,41,  44,96,  81,77,  48,145,  87,125,  152,108\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.96 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.457/0.823-mean/best, past_thr=0.512-mean: 19,23,  29,30,  26,50,  40,38,  45,59,  56,49,  86,42,  43,95,  82,77,  49,141,  87,125,  149,108\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.97 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.457/0.823-mean/best, past_thr=0.511-mean: 19,23,  28,30,  26,50,  41,38,  45,59,  57,50,  84,41,  44,94,  82,78,  49,144,  87,125,  148,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.95 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.456/0.823-mean/best, past_thr=0.511-mean: 19,23,  28,30,  26,50,  41,38,  45,59,  57,50,  85,41,  44,94,  81,78,  49,144,  87,125,  149,110\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.92 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.454/0.824-mean/best, past_thr=0.509-mean: 18,23,  28,30,  25,53,  42,36,  42,57,  57,50,  87,42,  42,97,  78,74,  47,146,  82,130,  144,112\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.93 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.454/0.824-mean/best, past_thr=0.510-mean: 18,23,  28,30,  25,51,  41,36,  44,57,  58,49,  85,43,  41,97,  78,77,  49,147,  80,129,  148,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.93 anchors past thr\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mEvolving anchors with Genetic Algorithm: fitness = 0.8244: 100%|███████| 500/500 [00:00<00:00, 1823.04it/s]\u001b[0m"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.454/0.824-mean/best, past_thr=0.510-mean: 18,24,  28,30,  25,51,  41,35,  44,56,  57,48,  85,43,  41,96,  78,77,  49,146,  81,131,  146,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.93 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.454/0.824-mean/best, past_thr=0.510-mean: 18,24,  28,30,  25,51,  41,35,  44,56,  57,48,  85,43,  41,96,  78,76,  49,146,  81,131,  146,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.94 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,23,  28,30,  25,52,  41,36,  44,55,  57,48,  85,42,  41,96,  78,76,  49,147,  81,130,  144,114\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.94 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,23,  28,30,  25,52,  41,36,  44,55,  57,48,  85,42,  41,96,  78,76,  49,147,  81,130,  144,114\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.96 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,24,  29,30,  25,51,  41,36,  44,55,  57,48,  84,43,  41,96,  78,76,  49,146,  81,130,  143,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.96 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,24,  28,30,  24,51,  41,37,  44,56,  57,49,  84,41,  41,95,  78,75,  50,149,  81,128,  141,115\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.97 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,24,  28,30,  24,51,  40,37,  43,56,  57,49,  84,42,  41,96,  78,76,  49,147,  81,128,  140,117\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mthr=0.25: 1.0000 best possible recall, 9.97 anchors past thr\n",
      "\u001b[34m\u001b[1mautoanchor: \u001b[0mn=12, img_size=408, metric_all=0.455/0.824-mean/best, past_thr=0.510-mean: 18,24,  28,30,  24,51,  40,37,  43,56,  57,49,  84,42,  41,96,  78,76,  49,147,  81,128,  140,117\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[     18.005,      23.542],\n",
       "       [     28.344,       29.61],\n",
       "       [     24.084,      50.908],\n",
       "       [     40.394,      36.521],\n",
       "       [     43.471,      55.795],\n",
       "       [     57.358,      49.031],\n",
       "       [     84.475,      41.545],\n",
       "       [     40.772,      95.747],\n",
       "       [     77.973,      76.087],\n",
       "       [     49.446,      147.06],\n",
       "       [     81.149,      127.96],\n",
       "       [     139.56,      116.81]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import autoanchor\n",
    "autoanchor.kmean_anchors(path='./data/germ.yaml', n=12, img_size=408, thr=4.0, gen=500, verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "832042e8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52e99c80",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
